goal = codesters.Point(-50, 100)
goal.set_size(2)
goal.set_color("purple")
goal.say("I'm the goal!")
stage.set_background("grid")
sprite = codesters.Sprite("triangle")
sprite.go_to(0,0)
try:
tval1 = sprite.get_x()
tval2 = sprite.get_y()
except:
tval1 = "DNE"
tval2 = "DNE"
if tval1 == -50 and tval2 == 100:
goal.say("")
# text = codesters.Text("Change the numbers in the Go To command to land the triangle's red vertex on the goal!", 0, 225, "blue")
# if tval1 == -50 and tval2 == 100:
# text.set_text("Great job!")
# text.set_color("green")
# elif tval1 == "DNE" or tval2 == "DNE":
# text.set_text("Oops! Did you delete your triangle sprite?")
# text.set_color("red")
# elif tval1 == 100 or tval2 == -50:
# text.set_text("Oops! Did you mix up your x and y coordinates?")
# text.set_color("orange")
# elif tval1 == 50:
# text.set_text("Make sure you count x values to the left of the origin as negative.")
# text.set_color("orange")
# elif tval2 == -100:
# text.set_text("Make sure you count y values above the origin as positive!")
# text.set_color("orange")
# elif tval1 != -50 and tval1 != "DNE":
# text.set_text("Change the numbers in the Go To command to land the triangle's red vertex on the goal!")
# elif tval2 != 100 and tval2 != "DNE":
# text.set_text("Change the numbers in the Go To command to land the triangle's red vertex on the goal!")
# else:
# text.set_text("Change the numbers in the Go To command to land the triangle's red vertex on the goal!")
t1 = TestObjective()
t1.add_success(tval1 == -50 and tval2 == 100, "Great job!")
t1.add_failure(tval1 == "DNE" or tval2 == "DNE", "Oops! Did you delete your triangle sprite?")
t1.add_failure(tval1 ==100 or tval2 == -50, "Oops! Did you mix up your x and y coordinates?")
t1.add_failure(tval1 == 50, "Make sure you count x values to the left of the origin as negative.")
t1.add_failure(tval2 == -100, "Make sure you count y values above the origin as positive!")
t1.add_failure(tval1 != -50 and tval1 != "DNE", "Keep changing the numbers in the Go To command to get the red dot on top of the goal.")
t1.add_failure(tval2 != 100 and tval2 != "DNE", "Keep changing the numbers in the Go To command to get the red dot on top of the goal.")
tester = TestManager()
tester.display_graphics = False
tester.add_test_list([t1])
tester.run_tests()
tester.display_first_feedback()
-
Run Code
-
Activity Submitted!
Submit Work
-
Next Activity
-
Stop Running Code
-
Show Chart
-
Show Console
-
Reset Code Editor
-
Codesters How To (opens in a new tab)